<template>

	<view class="wrapper">
		<uni-nav-bar  title="矿池" rightText="中文版" :backgroundColor="background" :color="color" :fixed="true"></uni-nav-bar>
		<view class="suanli_box">
			
			<view class="aside_left">
				<view class="content_box" @tap="$open('../bizhan/ore_buys')">
					<image src="../../static/bizhan/daxing.png" mode="aspectFill" class="diamond"></image>
					<view class="f30 cfff">挖矿</view>
						<view class="f24 cfff suan_num" >今日收益: {{ Mined.totalToday | toTwo(4) }} SMK</view>
					<view class="f26 cfff "> 总收益： {{ Mined.total  | toTwo(4) }}/{{ Mined.totalReserve }} SMK </view>
				</view>
				<view class="account_box">
				<!-- 	<view class="set_width">
						@tap="$open('ore_account')"
						<view class="f24 c1A6B36" >
						USDT账户
							<image src="../../static/bizhan/s3.png" mode="aspectFill" class="lv_arr"></image>
						</view>
						{{ applyData.member.poolAccount | toTwo(4)}}
						<view class="f24" style="color: #FF3A2F;">  {{money | toTwo(4)}} USDT</view>
					</view> -->
					<!-- <view class="set_width" @tap="$open('../user/wallet_pay')">
						<view class="f24 c1A6B36">
							钱包账户
							<image src="../../static/bizhan/s3.png" mode="aspectFill" class="lv_arr"></image>
						</view>
						<view class="f24" style="color: #FF3A2F;">{{ balance | toTwo(4) }} SMK</view>
					</view> -->
				</view>
			</view>
			<view class="aside_right center colum">
				<view class="gif_box">
					<image src="../../static/bizhan/s55.png" mode="aspectFit"></image>
					</view>
				<!-- <view class="f24 center gif_btn" @tap="$open('poolRecharge?balance=' + applyData.member.poolAccount)">燃烧挖矿</view> -->
			</view>
		</view>
		<view class="nav_box">
			<!-- @tap="$open('ore_trade?name=' + BiCoinInfo.biCoin.name)" -->
			<view class="one_nav" @tap="$open('../bizhan/ore_buy')">
				<image src="../../static/bizhan/s35.png" mode="aspectFill" class="nav_img"></image>
				<!-- <view class="nav_name">交易</view> -->
				<view class="nav_name">矿机</view>
			</view>
			<view class="one_nav" @tap="$open('turn_money?name=SMK&Uname=USDT&poolAccount=' + money + '&earnings=' + earnings)">
				<image src="../../static/bizhan/s36.png" mode="aspectFill" class="nav_img"></image>
				<view class="nav_name">划转</view>
			</view>
			<view class="one_nav" @tap="$open('ore_account')">
				<image src="../../static/bizhan/s37.png" mode="aspectFill" class="nav_img"></image>
				<view class="nav_name">明细</view>
			</view>
			<view class="one_nav" @tap="$open('ore_team')">
				<image src="../../static/bizhan/s38.png" mode="aspectFill" class="nav_img"></image>
				<view class="nav_name">团队</view>
			</view>
			<view class="one_nav" @tap="sao">
				<image src="../../static/bizhan/s56.png" mode="aspectFill" class="nav_img"></image>
				<view class="nav_name">扫一扫</view>
			</view>
<!-- 			<view class="one_nav">
				<image src="../../static/bizhan/lv.png" mode="aspectFill" class="nav_img"></image>
				<view class="nav_name">{{ applyData.memberLevel.levelName }}</view>
			</view> -->
		</view>
		<view class="my_zichan">我的资产</view>
		<view class="coin_box" v-if="limits.userType == 3">
			<view class="setFlex">
				<view class="coin_name"> 团队总额</view>
			</view>
			<view class="setFlex">
				<view class="assets">
					<view class="assets_nub_about">{{limits.sumMoney }} / U</view>
				</view>
			</view>
		</view>
		<view class="coin_box">
			<view class="setFlex">
				<image src="../../static/bizhan/smk.png" mode="" class="coin_img"></image>

				<view class="coin_name">{{BiCoinInfo.name}}</view>
			</view>
			<view class="setFlex">
				<view class="assets">
					<view class="assets_nub">{{ (balance + earnings )| toTwo(4)}}</view>
					<view class="assets_nub_about">≈ ${{((balance + earnings ) * BiCoinInfo.price ) | toTwo(4)}}</view>
				</view>
			</view>
		</view>
		<view class="coin_box">
			<!-- @tap="$open('ore_terminate')" -->
			<view class="setFlex" >
				<image src="../../static/bizhan/usdt.png" mode="" class="coin_img"></image>
				<view class="coin_name">
					USDT
				</view>
			</view>
			<view class="setFlex">
				<view class="assets">
					<view class="assets_nub">{{ money | toTwo(4)}}</view>
				</view>
				<!-- <view class="operate set_margin" @tap="$open('./showWalletCode?address=' + applyData.member.walletAddress)">
					<image src="../../static/bizhan/s27.png" mode="" class="operate_img"></image>
					充币
				</view>
				<view class="operate" @tap="$open('../user/wallet_tixian?balance=' + applyData.member.wallet.USDT)">
					<image src="../../static/bizhan/s28.png" mode="" class="operate_img"></image>
					提币
				</view> -->
			</view>
		</view>
		
		<view class="congz">
		<view class="conmg" @tap="$open('./showWalletCode?address=' + applyData)">
			<image class="operate_img" src="../../static/bizhan/s33.png" mode=""></image>
		<text>充币</text>
		</view>
		<!--  -->
		<view class="tixsan" @tap="Mention()">
			<image class="operate_img" src="../../static/bizhan/s34.png" mode=""></image>
			<text>提币</text>
		</view>
		</view>
		
		
		
		<view class="yield">
		<view class="survey_box">
			<text class="active fadc">信息概况</text>
			<text class="fadc shu">|</text>
			<text class="fadc" @tap="$open('./introduce')">{{BiCoinInfo.name}}简介</text>
		</view>
		<view class="price_box">
			<view class="aside_left1">
				<view class="aside_top">
					<view class="price_name">价格</view>
					<view class="price_num">${{ BiCoinInfo.price | toTwo(4) }}</view>
				</view>
		<!-- 		<view class="aside_bot">
					<view class="price_name">交易额</view>
					<view class="price_num">${{ BiCoinInfo.vol | toTwo(4) }}</view>
				</view> -->
			</view>
			<view class="aside_right1">
				<!-- <view class="aside_top">
					<view class="price_name">流通量</view>
					<view class="price_num">{{ BiCoinInfo.supply | toTwo(2) }}</view>
				</view> -->
				<view class="aside_bot">
					<view class="price_name">涨跌幅</view>
					<view class="price_num" :class="{ te:BiCoinInfo.change < 0  }">{{ BiCoinInfo.change| toTwo(2) }}%</view>
				</view>
			</view>
		</view>
			</view>
		<!-- <view class="max_min">最高/最低价</view>
		<view class="table_head">
			<view class="f24 c999">时间</view>
			<view class="f24 c999">最高</view>
			<view class="f24 c999">最低</view>
		</view> -->
		<!-- <view class="table_body">
			<view class="time_slot">
				<view class="time f26 cfff">昨天</view>
				<view class="max f26 cfff">${{ BiCoinInfo.biCoinHistory.yest.max | toTwo(4) }}</view>
				<view class="min f26 cfff">${{ BiCoinInfo.biCoinHistory.yest.min | toTwo(4) }}</view>
			</view>
			<view class="time_slot">
				<view class="time f26 cfff">7天</view>
				<view class="max f26 cfff">${{ BiCoinInfo.biCoinHistory.week.max | toTwo(4) }}</view>
				<view class="min f26 cfff">${{ BiCoinInfo.biCoinHistory.week.min | toTwo(4) }}</view>
			</view>
			<view class="time_slot">
				<view class="time f26 cfff">30天</view>
				<view class="max f26 cfff">${{ BiCoinInfo.biCoinHistory.month.max | toTwo(4) }}</view>
				<view class="min f26 cfff">${{ BiCoinInfo.biCoinHistory.month.min | toTwo(4) }}</view>
			</view>
			<view class="time_slot">
				<view class="time f26 cfff">90天</view>
				<view class="max f26 cfff">${{ BiCoinInfo.biCoinHistory.halfyear.max | toTwo(4) }}</view>
				<view class="min f26 cfff">${{ BiCoinInfo.biCoinHistory.halfyear.min | toTwo(4) }}</view>
			</view>
		</view> -->
	</view>

</template>

<script>

	import uniNavBar from '@/components/uni-nav-bar/uni-nav-bar.vue';

export default {
	data() {
		return {
			Mined:{},
			applyData:'',
			BiCoinInfo: {},
			balance: 0,
			flag:false,
			resultCode:'',
			money:'',
			background:'#0E1B45',
			color:'#fff',
			balances:'',
			resultCode:'',
			//收益
			earnings:'',
			limits:{}
			
		};
	},
	components: {  uniNavBar },
	onLoad(e) {
		this.resultCode = e.resultCode
		if (e.userId) {
			let userinfo = {
				userId: e.userId,
				access_token: e.access_token
			};
			uni.setStorageSync('userinfo', userinfo);
		}
		
	},

created() {
	 window.codeQR = this.codeQR
},
	onShow() {
	this.getMyInfo();
	},

	methods: {
		//扫一扫
		sao(){
			if( uni.getSystemInfoSync().platform === 'android'){
			//安卓
			Android.scanning();	
			}else if( uni.getSystemInfoSync().platform == 'ios'){
				//苹果
				window.webkit.messageHandlers.scanning.postMessage({});
			}

		},
			codeQR(QRV){
					this.$open('/pages/bizhan/ore_QR?result='+QRV)
			},
		//提币
		Mention(){
			this.$open('../user/wallet_tixian?balance=' +this.balances)
			// if(this.resultCode == 1){
			// 	this.$sToast('需要全部解约')
			// }else {
				
			// }
		},
		openUrl(url) {
			// #ifdef APP-PLUS
			plus.runtime.openWeb(url);
			// #endif

			// #ifdef H5
			window.location.href = url;
			// #endif
		},
		getMyInfo() {
			this.$ajax(
			this.apiList.MinedByUserId,
			{
			userId:uni.getStorageSync('userinfo').userId
			},
			'POST'
			).then(res=>{
				this.Mined = res.data
			})
			this.$ajax(
		'bi/getUSDTNumber',
		{
			userId: uni.getStorageSync('userinfo').userId
		},
		'POST'
			).then(res=>{
				this.money = res.data
			})
			this.$ajax(
				'bi/getMyInfo',
				{
					userId: uni.getStorageSync('userinfo').userId
				},
				'POST'
			).then(res => {
	this.applyData = res.data.address;
		// console.log(this.applyData)
		// 	 if( res.data.member.wallet == null ){
		// 		  res.data.member.wallet = ''
		// 	 }else {
		// 		 res.data.member.wallet = JSON.parse(res.data.member.wallet) 
		// 	 }
	
			});
		//USDT
			this.$ajax('bi/getMyWallet',
			{
					userId: uni.getStorageSync('userinfo').userId
			},
			 'POST'
			 ).then(res => {
				// console.log(res.data.balance)
				this.balances = res.data.balance;
			});
				//余额
			this.$ajax(this.apiList.getUserMoeny).then(res => {
				if (res.data.balance > 0) {
					this.balance = res.data.balance;
				}
			});
			//收益
			this.$ajax('bi/getSMKProfitNumber',
			{
					userId: uni.getStorageSync('userinfo').userId
			},
			 'POST'
			 ).then(res => {
				// console.log(res.data)
				this.earnings = res.data;
			});
		this.$ajax('bi/getIndexBiRank', {}, 'POST').then(res => {
			this.BiCoinInfo = res.data;
		});
		//提币限制
		this.$ajax(
		this.apiList.getAllUnEntrust,
		{
			userId:uni.getStorageSync('userinfo').userId
		},
		'POST'
		).then(res=>{
			this.resultCode = res.data
		})
		
		this.$ajax(
		'user/getTeamUdunMoney',
		{
		userId:uni.getStorageSync('userinfo').userId	
		},
		"POST"
		).then(res=>{
		this.limits = res.data
		})
		
		
		}
	}
};
</script>

<style lang="scss">
	.wrapper {
		background-color: #0E1B45;
	}
.suanli_box {
	width: 690rpx;
	height: 310rpx;
	// background: #000000;
	background: url(../../static/bizhan/s22.png) no-repeat;
	background-size: 100% 100%;
	border-radius: 12rpx;
	display: flex;
	flex-direction: row;
	justify-content: space-between;
	margin: 9rpx 30rpx 36rpx 30rpx;
}
.yield {
	background: url(../../static/bizhan/s29.png) no-repeat;
	background-size: 100% 100%;
	width: 100%;
	box-sizing: border-box;
	margin-top: 20upx;
	height: 80px;
}
.aside_left {
	margin: 10rpx 0 0 10rpx;
}
.diamond {
	width: 100rpx;
	height: 100rpx;
	margin-bottom: 9rpx;
}
.suan_num {
	margin: 22rpx 0 17rpx 0;
}
.lv_arr {
	width: 8rpx;
	height: 16rpx;
	margin-left: 9rpx;
}
.title{
	text-align: center;
	padding:  30upx 20upx;
	.set_width{
		margin-left: 20upx;
	}
	.buy {
		width: 256rpx;
		height: 82rpx;
		margin-bottom: 40upx;
		display: inline-block;
		
	}
}

.f30 {
	line-height: 30rpx;
}
.f24 {
	line-height: 24rpx;
}
.c1A6B36 {
	color: #00b34d;
	font-weight: bold;
	margin: 26rpx 0 16rpx 0;
}
.account_box {
	display: flex;
	flex-direction: row;
}
.gif_box {
	width: 250rpx;
	height: 250rpx;
	margin: 22rpx 0;
	image {
		width: 100%;
		height: 100%;
	}
}
.aside_right {
	margin-right: 54rpx;
	.gif_btn {
		border: 1rpx solid #0297fe;
		height: 50rpx;
		border-radius: 44rpx;
		color: #ff3543;
		width: 160rpx;
	}
}
.set_width {
	width: 210rpx;
}
.nav_box {
	display: flex;
	flex-direction: row;
	margin-left: 15rpx;
	background-color: #0D1D4C;
	justify-content: space-between;
	padding: 30upx;
}
.nav_img {
	width: 46rpx;
	height: 46rpx;
}
.nav_name {
	font-size: 26rpx;
	line-height: 44rpx;
	white-space: nowrap;
	width: 50rpx;
	display: flex;
	justify-content: center;
	color: #fff;

}
.one_nav {
	margin: 0 35rpx;
}
.my_zichan {
	font-size: 30rpx;
	font-weight: bold;
	color: #fff;
	margin: 40rpx 0 0 30rpx;
}
.coin_box {
	display: flex;
	flex-direction: row;
	justify-content: space-between;
	align-items: center;
	width: 690rpx;
	height: 157rpx;
	background: #0D1D4C;
	box-shadow: 0rpx 0rpx 16rpx 0rpx rgba(2, 151, 254, 0.1);
	border-radius: 12rpx;
	margin: 30rpx 0 0 30rpx;
	padding: 0 20rpx 0 20rpx;
	border: 1upx solid #20D6D9;
	border-radius: 10upx;
}
.setFlex {
	display: flex;
	flex-direction: row;
	align-items: center;
	padding: 40upx;
}
.coin_img {
	width: 64rpx;
	height: 64rpx;
	margin-right: 32rpx;
}
.coin_name {
	font-size: 34rpx;
	font-weight: bold;
	color:#fff;
	line-height: 34rpx;
	.c999{
		margin-top: 10rpx;
	}
}
.assets {
	display: flex;
	flex-direction: column;
	align-items: flex-end;
}
.operate_img {
	width: 60rpx;
	height: 60rpx;
	margin-right: 10upx;
	vertical-align: middle;
}
.operate {
	display: flex;
	flex-direction: column;
	font-size: 22rpx;
	text-align: center;
	color: #fff;
}
.assets_nub {
	font-size: 30rpx;
	line-height: 30rpx;
	color: #fff;
}
.assets_nub_about {
	font-size: 26rpx;
	color: #fff;
}
.set_margin {
	margin: 0 30rpx 0 30rpx;
}
.fadc {
	font-size: 25rpx;
	color: #fff;
}
.active {
	color: #fff;
}
.survey_box {
	text-align: center;
	line-height: 30upx;
	width: 50%;
	margin: 0 auto;
}
.price_box {
	display: flex;
	flex-direction: row;
	padding: 28rpx 30rpx 0 30rpx;
	justify-content: space-between;
}
.aside_top,
.aside_bot {
	display: flex;
	flex-direction: row;
	justify-content: space-between;
	width: 325rpx;
	margin-bottom: 29rpx;
}
.price_name {
	font-size: 26rpx;
	line-height: 26rpx;
	color: #C6C6C6;
}
.price_num {
	font-size: 26rpx;
	line-height: 26rpx;
	color: #fff;
}
.te {
	color: red;
}
.max_min {
	font-size: 30rpx;
	line-height: 30rpx;
	font-weight: bold;
	color:#fff;
	background: url(../../static/bizhan/s30.png) no-repeat;
	background-size: 100% 100%;
	width: 50%;
	height: auto;
	margin: 20upx auto 0;
	text-align: center;
	padding: 20upx;
	
}
.table_head {
	display: flex;
	flex-direction: row;
	justify-content: space-between;
	padding: 0 30rpx 0 30rpx;
	margin-top: 28rpx;
}
.time_slot {
	display: flex;
	flex-direction: row;
	justify-content: space-between;
	border-bottom: 1rpx solid #20D6D9;
	margin-left: 30rpx;
	line-height: 94rpx;
}
.time {
	width: 80rpx;
}
.min {
	width: 230rpx;
	margin-right: 30rpx;
	display: flex;
	flex-direction: row;
	justify-content: flex-end;
}
.shu {
	margin: 0 20rpx 0 20rpx;
}
.max {
	width: 200rpx;
	display: flex;
	flex-direction: row;
	justify-content: flex-end;
}
.congz {
	width: 100%;
	height: auto;
	padding: 30upx;
	margin: 20upx 0;
	display: flex;
	justify-content: space-between;
	.conmg {
		width: 165px;
		height: 46px;
		background: url(../../static/bizhan/s32.png) no-repeat;
		background-size: 100% 100%;
		display: flex;
		align-items: center;
		justify-content: center;
		color: #fff;
	}
	.tixsan {
		display: flex;
		align-items: center;
		justify-content: center;
		color: #fff;
		
	width: 165px;
	height: 46px;
	background: url(../../static/bizhan/s31.png) no-repeat;
	background-size: 100% 100%;	
	}
}
</style>
